<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>产品管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%@include file="/common/header.jsp"%>
    
</head>

<body>
    <div class="container " style="margin-top: 20px">
    <%@include file="/common/top.jsp"%>
    <div class="row">
        <div class="col-sm-3">
            <%@include file="/common/menu.jsp"%>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">产品管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/product" method="post">
                                                关键字：
                <input type="text" name="keyword" value="${qo.keyword}"
                    placeholder="产品名称/供应商" style="width: 180px;text-align: center;">
                                                售价：
                <input type="number" min="0" name="minSalePrice" value="${qo.minSalePrice}"
                    placeholder="最低售价" style="width: 180px;text-align: center;">
                -
                <input type="number" min="0" name="maxSalePrice" value="${qo.maxSalePrice}"
                    placeholder="最高售价" style="width: 180px;text-align: center;">&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:goPage(1)" class="btn btn-success">查询</a>
                <a href="/product?cmd=input" class="btn btn-success">添加产品</a>
                <br/><br/>

                <table class="table table-striped table-hover" >
                    <thead> 
                        <tr>
                            <th>序号</th>
                            <th>产品编号</th>
                            <th>产品名称</th>
                            <th>产品分类</th>
                            <th>售价</th>
                            <th>供应商</th>
                            <th>品牌</th>
                            <th>折扣</th>
                            <th>成本价</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <c:forEach items="${result.list}" var="product" varStatus="vs">
                    <tr>
                       <td>${vs.count + (result.currentPage-1)*result.pageSize}</td>
                       <td>${product.id}</td>
                       <td>${product.productName}</td>
                       <td>${product.dirId}</td>
                       <td>${product.salePrice}</td>
                       <td>${product.supplier}</td>
                       <td>${product.brand}</td>
                       <td>${product.cutoff}</td>
                       <td>${product.costPrice}</td>
                       <td>
                           <a class="btn btn-info btn-xs" href="/product?cmd=input&id=${product.id}">
                               <span class="glyphicon glyphicon-pencil"></span>编辑
                           </a>
                           <a href="/product?cmd=delete&id=${product.id}" class="btn btn-danger btn-xs" >
                               <span class="glyphicon glyphicon-trash"></span>删除
                           </a>
                       </td>
                    </tr>
                    </c:forEach>
                    
                </table>
                <nav aria-label="Page navigation">
                    <a href="javascript:goPage(1)">首页</a>&nbsp;&nbsp; 
                    <a href="javascript:goPage(${result.prevPage})">上页</a>&nbsp;&nbsp; 
                    <a href="javascript:goPage(${result.nextPage})">下页</a>&nbsp;&nbsp; 
                    <a href="javascript:goPage(${result.totalPage})">尾页</a>&nbsp;&nbsp; 
                                                            当前第${result.currentPage} / ${result.totalPage} 页&nbsp;&nbsp;
                                                            共 ${result.totalCount}条数据&nbsp;&nbsp;
                                                            到<input id="currentPage" type="number" value="${result.currentPage}"  style="text-align: center;"
                            name="currentPage"
                            onchange="" min="1" max="${result.totalPage}">页&nbsp;&nbsp;
                    <input type="submit" value="跳转">
                                                            显示<select name="pageSize" onchange="goPage(1)">
                        <option value="5" ${result.pageSize == 5 ? 'selected' : ''}>5</option>
                        <option value="7" ${result.pageSize == 7 ? 'selected' : ''}>7</option>
                        <option value="10" ${result.pageSize == 10 ? 'selected' : ''}>10</option>
                    </select>
                                                            条
                </nav>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    function goPage(currentPage){
        if (currentPage != null) {
            document.getElementById("currentPage").value = currentPage;
            document.forms[0].submit();
        }      
    }
</script>
</body>
</html>